package Array;

public class array {

    public static void main(String[] args) {

        /**
         * 一维数组
         */
        int[] arr1 = {1, 2, 3, 4};
        int[] arr2 = new  int[4];
        arr2[0] = 1;
        arr2[1] = 2;
        arr2[2] = 3;
        arr2[3] = 4;

        /* 遍历数组 */
        for (int j = 0; j < arr1.length; j++) {
            System.out.println("index:"+j+",value:"+arr1[j]);
        }
        for (int i : arr2) {
            System.out.println(i);
        }


        /**
         * 多维数组
         */
        int arr3[][] = new int[2][2];
        arr3[0][0]=4;
        arr3[0][1]=3;
        arr3[1][0]=2;
        arr3[1][1]=1;
        for (int i = 0; i < arr3.length; i++) 
        {
            for (int j = 0; j < arr3[i].length; j++) {
                System.out.println(arr3[i][j]);
            }
        }
    }
}
